package com.cet.util;

import com.fasterxml.jackson.core.type.TypeReference;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;

import java.util.Map;

/**
 * @author NSOC
 */
public class ObjectConvertUtil {

    private ObjectConvertUtil() {

    }

    public static Map<String, Object> convertObjectToMap(Object object) {
        ObjectMapper objectMapper = new ObjectMapper();
        // 序列化LocalDateTime
        objectMapper.registerModule(new JavaTimeModule());
        return objectMapper.convertValue(
                object,
                new TypeReference<Map<String, Object>>() {
                }
        );
    }
}
